package com.dong.mcd.pub;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.support.SqlSessionDaoSupport;

public class PublicDaoImpl extends SqlSessionDaoSupport implements IPublicDao {

	public List<?> selectPage(String sqlMap, Object param, int offset, int limit) {
		SqlSession session = null;
		try {
			session = this.getSqlSession();
			return session.selectList(sqlMap, param, new RowBounds(offset, limit));
		} finally {
			if (session != null)
				session.close();
		}
	}

	public List<?> selectPage(String sqlMap, int offset, int limit) {
		return selectPage(sqlMap, DEFAULT_PARAM, offset, limit);
	}

	public List<?> selectPage(Class<?> mapperCls,Object param, int offset, int limit) {
		if (mapperCls != null){
			if (param == null)
				return selectPage(mapperCls.toString()+"."+QUERY_PAGE_SQLMAP_ID, offset, limit);
			else
				return selectPage(mapperCls.toString()+"."+QUERY_PAGE_SQLMAP_ID,param, offset, limit);
		}
		return null;
	}

}
